#!/bin/sh

# call with a command like
#	% CFLAGS="-O3" ./profile.sh

# compile profile generation information
make clean
make CFLAGS="$CFLAGS -fprofile-generate"

# gather profile data
cat check/test.e check/math.e | ./econs

# recompile using profile data
make mostlyclean
make CFLAGS="$CFLAGS -fprofile-use"

# FIXME this actually generates a binary that runs 50%+ slower in i586,
# FIXME at least for some small test cases with like 10 million iterations
# FIXME doing some not useful computation (like addition or swap of values)
#
# FIXME build replacing the call to "cat ...|./econs" was done to ensure it
# FIXME would still generate an worse binary when only gathering profile
# FIXME from one such test
#
# FIXME check on x86_64
